﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using T.ServiceComponent.Config.Client;

namespace T.FAS.Runtime.ScheduleJob.Engine
{
    public class ConfigUtil
    {
        private static ConfigUtil instance = new ConfigUtil();
        private string _AuthUserId;
        private string _isAtInSubscription;
        private static readonly object _lock = new object();
        private ConfigUtil()
        {
        }

        public static ConfigUtil Instance
        {
            get
            {
                return instance;
            }
        }
        /// <summary>
        /// 资源服务Domain
        /// </summary>       
        public string AuthUserId
        {
            get
            {
                if (string.IsNullOrEmpty(_AuthUserId))
                {
                    lock (_lock)
                    {
                        if (string.IsNullOrEmpty(_AuthUserId))
                        {
                            try
                            {
                                _AuthUserId = ConfigurationManager.AppSettings["Fas.ScheduleJob.AuthUserId"];
                                if (string.IsNullOrEmpty(_AuthUserId))
                                    _AuthUserId = ConfigManager.GetConfigValue("Fas.ScheduleJob.AuthUserId");
                                if (string.IsNullOrEmpty(_AuthUserId))
                                    _AuthUserId = "999";
                            }
                            catch
                            {
                                _AuthUserId = "999";
                            }
                        }
                    }
                }
                return _AuthUserId;
            }
        }
    }
}
